class Solution:
    def singleNumber(self, nums) -> int:
        had = set()
        for i in nums:
            if i in had:
                had.remove(i)
            else:
                had.add(i)
        return had.pop()

if __name__ == '__main__':
    so = Solution()
    nums = [2,2,1]
    re = so.singleNumber(nums)
    print(re)
